import { request } from '@inbiz/utils';

/**
 * 查询分组列表
 * @param data
 */
export async function getGroupList(data: any) {
  const { all, ...params } = data;
  return request(
    `/inbiz/api/services/${all ? 'front/' : ''}engines/v${
      InbizConfig.API_VERSION
    }/pageGroup/loadGroupList`,
    {
      params,
      appId: params.appId,
    },
  );
}

/**
 * 获取某个分组下的页面
 * @param params
 */
export async function getGroupPageList(data: any) {
  const { all, ...params } = data;
  return request(
    `/inbiz/api/services/${all ? 'front/' : ''}engines/v${
      InbizConfig.API_VERSION
    }/pageGroup/loadPageList`,
    {
      params: params,
      appId: params.appId,
    },
  );
}

/**
 * 获取站点列表及站点下分组树
 * @param params
 */
export async function getPermTree(params: {
  isQuerySite: boolean;
  siteType: 0 | 1;
  appId?: string;
  siteOutId?: string;
}) {
  return request(
    `/inbiz/api/services/front/engines/v${InbizConfig.API_VERSION}/page/loadSitePermTreeList`,
    {
      params: params,
      appId: params.appId,
      siteOutId: params.siteOutId,
    },
  );
}
/**
 * 获取站点列表
 * @param params
 */
export async function getAppList(params: { MaxResultCount: number }) {
  return request(`/inbiz/api/services/engines/v${InbizConfig.API_VERSION}/app/pagedList`, {
    params: params,
  });
}
